package com.edu.controller;

import com.edu.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/json2")
public class JsonController2 {

    @RequestMapping("/test1")
    //@RequestBody 作用是把请求参数中的json字符串 转换成java里的对象
    @ResponseBody
    public Object test1(@RequestBody String msg){
        System.out.println(msg);
        return "succees";
    }


    @RequestMapping("/test2")
    @ResponseBody
    public Object test2(String msg){
        System.out.println(msg);
        return "succees";
    }

    @RequestMapping("/test3")
    @ResponseBody
    public Object test3(User user){
        System.out.println(user);
        return "succees";
    }

    @RequestMapping("/test4")
    @ResponseBody
    public Object test4(@RequestBody User user){
        System.out.println(user);
        return "succees";
    }

    @RequestMapping("/test5")
    @ResponseBody
    public Object test5(@RequestBody Map map){
        System.out.println(map);
        return "succees";
    }

    @RequestMapping("/test6")
    @ResponseBody
    public Object test6(@RequestBody List<User> users){
        System.out.println(users);
        System.out.println(users.size());
        return "succees";
    }

}
